const webpack = require("webpack");
const path = require("path");
const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");

const _date = new Date().getTime().toString();
const _outpath = "[name].bundle." + "js";

module.exports = {
    module: {
        loaders: [{
                test: /\.jsx$|\.js$/,
                loader: "babel-loader?presets[]=react,presets[]=es2015",
                include: path.join(__dirname, '/app/reactProject')
            },
            {
                test: /.(png|jpg)$/,
                loader: 'url-loader?limit=8192',
                include: path.join(__dirname, '/app/static/attract_investment/cssImg')

            },
            {
                test: /\.css$/,
                loaders: ["style", "css"],
                include: path.join(__dirname, '/app/css')

            }
        ]
    },
    entry: {
        app: [
            "./app/reactProject/app.jsx"
        ],
        vendor: ["react", "react-dom", "react-router", "react-redux", 'react-fastclick', "redux", "iscroll", "islider.js", "jquery", "lodash", "react-iscroll", "immutable"]
    },
    output: {
        path: path.join(__dirname, '/app/bundle'),
        filename: _outpath,
        publicPath: '/bundle/'
    },
    resolve: {

    },
    compiler: {
        stats: {
            colors: true
        }
    },
    plugins: [
        new CommonsChunkPlugin({
            name: "vendor",
            minChunks: Infinity
        }),
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            }
        })
    ]
};